<%@page import="model.dto.League"%>
<%@page import="java.util.ArrayList"%>
<%@page import="model.dto.Country"%>
<jsp:include page="include/header.jsp"/>		
		

		<div class="wrapper">
			<!-- BEGIN TOP NAV -->
			<jsp:include page="include/sidebar-top.jsp"/>
			<!-- END TOP NAV -->
			
			<!-- BEGIN SIDEBAR LEFT -->
			<jsp:include page="include/sidebar-left.jsp"/>
			<!-- END SIDEBAR LEFT -->
			
			
			<!-- BEGIN SIDEBAR RIGHT -->
			<jsp:include page="include/sidebar-right.jsp"/>
			<!-- END SIDEBAR RIGHT -->
			
			
			<!-- BEGIN PAGE CONTENT -->
			<div class="page-content">
				<div class="container-fluid">
				
<!--============================================= Add your content here ========================================-->
					
					<!-- Begin page heading -->
					<h1 class="page-heading">ADD LEAGUE <small>new league</small></h1>
					<!-- End page heading -->

		<div class="row">
						 <div class="col-sm-3 col-md-3">
							<a href="#fakelink" class="thumbnail">
						  		<img src="assets/img/photo/small/img-1.jpg" alt="Image" id="image_thumbnail">
							</a>
					  	</div><!-- /.ol-xs-6 col-md-3 -->
						<div class="col-sm-8">
							<div class="panel panel-info">
							  <div class="panel-heading">
								<h3 class="panel-title">New League</h3>
							  </div>
							  <div class="panel-body">
								<form id="form"  class="form-horizontal" action="add-league-process.sp" method="post" enctype="multipart/form-data">
									<fieldset>
										<legend></legend>
										<div class="form-group">
											<label class="col-lg-3 control-label">Country Name</label>
											<div class="col-lg-9">
												<select id="country_id" name="country_id" data-placeholder="Choose a Country..." class="col-lg-12 form-control chosen-" tabindex="2">
													
												</select>
											</div>
										</div>
										<input type="hidden" id="league_id" name="league_id">
										<div class="form-group">
											<label class="col-lg-3 control-label">League Name<span class="text-danger">*</span></label>
											<div class="col-lg-9">
												<input type="text" class="form-control require" id="league_name" name="league_name" />
											</div>
										</div>
										<div class="form-group">
											<label class="col-lg-3 control-label">League Image</label>
											<div class="col-lg-9">
													<div class="input-group">
														<input type="text" class="form-control" id="league_image" name="league_image" readonly>
														<span class="input-group-btn">
															<span class="btn btn-default btn-file" id="image_browser">
																Browse&hellip; <input type="file" name="abc1">
															</span>
														</span>
													</div><!-- /.input-group -->
											</div>
										</div>
										<div class="form-group">
											<label class="col-lg-3 control-label"></label>
											<div class="col-lg-9">
													<div class="input-group pull-right">
														<a  href="index.sp" class="btn btn-warning btn-perspective ">Cancel</a>&nbsp;
														<button id="btn_send" class="btn btn-info btn-perspective ">Save</button>
													</div><!-- /.input-group -->
											</div>
										</div>
									</fieldset>

																
								</form>
								
							  </div><!-- /.panel-body -->
							  <div class="panel-footer">
							  	
							  </div>
							</div><!-- /.panel panel-info -->
						</div><!-- /.col-sm-4 -->
		</div>
		
		<%
		League dto=(League)request.getAttribute("dto");
		int pageNumber=1;
		if(request.getAttribute("page")!=null){
			pageNumber=Integer.parseInt(request.getAttribute("page").toString());
		}
		%>
		
		
	 	<%if(dto!=null){%>
		<script type="text/javascript">
		$(document).ready(function() {
			$.post("get-all-country.sp", {
			}, function(data) {
				createOptionByJson(document.getElementById("country_id"),data,<%=dto.getCountryId()%>);		
			});
			document.getElementById("league_id").value="<%=dto.getId()%>";
			document.getElementById("league_name").value="<%=dto.getName()%>";
			document.getElementById("league_image").value="<%=dto.getImage()%>";
			document.getElementById("btn_send").innerHTML="Update";
			document.getElementById("form").action="update-league-process.sp?page="+<%=pageNumber%>;
			document.getElementById("image_thumbnail").src="../upload/league/<%=dto.getImage()%>";
		});
			
		</script>
		
		<%}else{ %>
			<script type="text/javascript">
					$(document).ready(function() {
						$.post("get-all-country.sp", {
						}, function(data) {
							createOptionByJson(document.getElementById("country_id"),data,"");		
						});
					});
		</script>		
		<%} %>
					 		
					
					
					
					
					
					
					
					
					
<!--============================================ End your content ============================================-->
				
					
				</div><!-- /.container-fluid -->
				

				<!-- BEGIN SIDEBAR BOTTOM -->
				<jsp:include page="include/sidebar-bottom.jsp"/>
				<!-- END SIDEBAR BOTTOM -->
				
				
			</div><!-- /.page-content -->
		</div><!-- /.wrapper -->
		<!-- END PAGE CONTENT -->


<jsp:include page="include/footer.jsp"/>			
				
				
